<template>
	<view class="upload-img">
		<view class="list">
			<view class="singleImg" v-for="(img, sub) in imgLists" :key="sub">
				<image :src="img" :lazy-load="true" mode="aspectFill" @click="previewImg()"></image>
				<view class="remove" @click="removeImg(sub)">
					<text class="iconfont remove-img">&#xe628;</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			};
		},
		props: ['imgLists'],
		
		methods: {
			previewImg() { //图片预览
				uni.previewImage({
					urls: this.imgLists,
					// current: index,
					indicator: 'number'
				});
			},
			removeImg(index) { // 移除图片
				console.log(this.imgLists)
				this.imgLists.splice(index, 1);
				this.$emit('func', this.imgLists)
				console.log(this.imgLists)
			},
		}
	}
</script>

<style lang="scss" scoped>
	// @import './uploadImg.scss';
	
.upload-img{
	width: 100%;
	height: 100%;
		.list{
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;
			.singleImg{
				width: 100%;
				height: 100%;
				position: relative;
				image{
					width: 100%;
					height: 100%;
					// border-radius: 8upx;
				}
				.remove{
					width: 50upx;
					height: 50upx;
					line-height: 50upx;
					text-align: center;
					background-color: red;
					border-radius: 0 8upx 0 0;
					position: absolute;
					top: 0;
					right: 0;
					z-index: 3;
					.remove-img{
						font-size: 20upx;
						color: #fff;
					}
				}
			}
		}
	// }
	
}
</style>
